#include <OgreConfigFile.h>
#include <OgrePrerequisites.h>

#define DLL_EXPORT __declspec(dllexport)

using namespace Ogre;

extern "C" DLL_EXPORT ConfigFile *getConfigFile()
{
    return new ConfigFile;
}

extern "C" DLL_EXPORT void call_ConfigFile_load(ConfigFile* ptr, const char *filename, const char *seperators, bool trimWhitespace)
{
    ptr->load(filename, seperators, trimWhitespace);
}




//ConfigFile::SectionIterator
extern "C" DLL_EXPORT ConfigFile::SectionIterator *call_getSectionIterator(ConfigFile *ptr)
{
	ConfigFile::SectionIterator *si = new ConfigFile::SectionIterator(ptr->getSectionIterator());
    return si;
}

extern "C" DLL_EXPORT bool call_SectionIterator_hasMoreElements(ConfigFile::SectionIterator *ptr)
{
	return ptr->hasMoreElements();
}

extern "C" DLL_EXPORT const char *call_SectionIterator_peekNextKey(ConfigFile::SectionIterator *ptr)
{
	return ptr->peekNextKey().c_str();
}

extern "C" DLL_EXPORT ConfigFile::SettingsMultiMap *call_getNext(ConfigFile::SectionIterator *ptr)
{
	ConfigFile::SettingsMultiMap *smm = new ConfigFile::SettingsMultiMap(*(ptr->getNext()));
	return smm;
}



//ConfigFile::SettingsMultiMap::iterator
extern "C" struct mm
{
	const char *first;
	const char *second;
};

typedef void(*caller_smm_iter)(mm setting, void *container);

extern "C" DLL_EXPORT void iter_ConfigFile_SettingsMultiMap(ConfigFile::SettingsMultiMap *ptr, caller_smm_iter func, void *container)
{
	Ogre::ConfigFile::SettingsMultiMap::iterator i;
	for(i = ptr->begin(); i != ptr->end(); ++i)
	{
		mm res;
		res.first = i->first.c_str();
		res.second = i->second.c_str();
		func(res, container);
	}
}